//
//  JLHeadlineCell.m
//  LIangeNews
//
//  Created by sun on 16/1/17.
//  Copyright © 2016年 sun. All rights reserved.
//

#import "JLHeadlineCell.h"
#import <UIImageView+WebCache.h>
#import "JLHeadline.h"
@interface JLHeadlineCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *replyCountLabel;
@property (weak, nonatomic) IBOutlet UIImageView *twoImageView;
@property (weak, nonatomic) IBOutlet UIImageView *threeImageView;
@end
@implementation JLHeadlineCell
+(NSString *)headlineCellWithIdentifier:(JLHeadline *)headline{
    if (headline.isBigImage) {
        return @"BigImageCell";
    }
    if (headline.imgextra.count == 2) {
        return @"ImagesCell";
    }
    return @"NewsCell";
}

-(void)setHeadline:(JLHeadline *)headline{
    _headline = headline;
    self.titleLabel.text = headline.title;
    self.detailTitleLabel.text = headline.digest;
    self.replyCountLabel.text = [NSString stringWithFormat:@"%d人回帖",headline.replyCount];
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:headline.imgsrc] placeholderImage:[UIImage imageNamed:@"loading"]];
    if (headline.imgextra.count == 2) {
        NSString * twoStrUrl = headline.imgextra[0][@"imgsrc"];
        [self.twoImageView sd_setImageWithURL:[NSURL URLWithString:twoStrUrl] placeholderImage:[UIImage imageNamed:@"loading"]];
        NSString * threeStrUrl = headline.imgextra[1][@"imgsrc"];
        [self.threeImageView sd_setImageWithURL:[NSURL URLWithString:threeStrUrl] placeholderImage:[UIImage imageNamed:@"loading"]];
    }
}
@end
